﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMSModel;

public partial class Import_bbs_add : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            bd();
        }
    }

    void bd()
    {
        CMSModel.CMSEntities dal = DAL.DBManager.GetCmsEmtity();
        ddlNewType1.DataSource = dal.NewsType.Where(x => string.IsNullOrEmpty(x.pid) && x.enable == 1);
        ddlNewType1.DataTextField = "name";
        ddlNewType1.DataValueField = "id";
        ddlNewType1.DataBind();
        ddlNewType1.Items.Insert(0, new ListItem("选择", ""));
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        CMSModel.CMSEntities dal = DAL.DBManager.GetCmsEmtity();
        BBSMatching c = new BBSMatching();
        c.BbsId = txtBBSId.Text;
        c.BBSName = txtBBSName.Text;
        c.localTypeId = Request["ddlNewType2"];
        dal.AddToBBSMatching(c);
        dal.SaveChanges();
        ClientScript.RegisterStartupScript(GetType(), "aa", "alert('添加成功');document.location='Default.aspx'", true);
    }
}